Intro Thoughts

Status Quo

library(tidyverse)

Experiment

extgalleryhtml <- read_lines("https://exts.ggplot2.tidyverse.org/gallery/")

"https://raw.githubusercontent.com/lionel-/ggstance/refs/heads/main/NAMESPACE"
## [1] "https://raw.githubusercontent.com/lionel-/ggstance/refs/heads/main/NAMESPACE"
"https://raw.githubusercontent.com/rcorty/ggQQunif/refs/heads/main/NAMESPACE"
## [1] "https://raw.githubusercontent.com/rcorty/ggQQunif/refs/heads/main/NAMESPACE"
"https://raw.githubusercontent.com/statsmaths/ggimg/refs/heads/master/NAMESPACE"
## [1] "https://raw.githubusercontent.com/statsmaths/ggimg/refs/heads/master/NAMESPACE"
extgalleryhtml %>% 
  str_detect("github.com/.+/gg.+") %>% 
  extgalleryhtml[.] %>% 
  str_extract("github.com/([a-zA-Z]|-)+/gg[a-zA-Z]+") %>% 
  unique() %>% 
  data.frame(repo_name = .) %>% 
  mutate(repo_name = str_remove(repo_name, "github.com/")) %>% 
  remove_missing() %>% 
  mutate(namespace_url = paste0("https://raw.githubusercontent.com/", 
                              repo_name, 
                              "/refs/heads/master/NAMESPACE")) ->
extensions_df
## Warning: Removed 1 row containing missing values or values outside the scale
## range.
len <- nrow(extensions_df)

namespace_contents <- vector(mode='list', len)

for (i in 1:len){
  
  try(
  namespace_contents[[i]] <-  read_lines(extensions_df$namespace_url[i])
   )
  
  # if(!exists(namespace_contents[[i]])){}
  
  Sys.sleep(.2)
}
## Error in open.connection(structure(4L, class = c("curl", "connection"), conn_id = <pointer: 0x1f8>),  : 
##   HTTP error 404.
## Error in open.connection(structure(5L, class = c("curl", "connection"), conn_id = <pointer: 0x1ff>),  : 
##   HTTP error 404.
## Error in open.connection(structure(4L, class = c("curl", "connection"), conn_id = <pointer: 0x203>),  : 
##   HTTP error 404.
## Error in open.connection(structure(5L, class = c("curl", "connection"), conn_id = <pointer: 0x207>),  : 
##   HTTP error 404.
## Error in open.connection(structure(6L, class = c("curl", "connection"), conn_id = <pointer: 0x209>),  : 
##   HTTP error 404.
## Error in open.connection(structure(7L, class = c("curl", "connection"), conn_id = <pointer: 0x20d>),  : 
##   HTTP error 404.
## Error in open.connection(structure(8L, class = c("curl", "connection"), conn_id = <pointer: 0x20f>),  : 
##   HTTP error 404.
## Error in open.connection(structure(9L, class = c("curl", "connection"), conn_id = <pointer: 0x210>),  : 
##   HTTP error 404.
## Error in open.connection(structure(10L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(4L, class = c("curl", "connection"), conn_id = <pointer: 0x21b>),  : 
##   HTTP error 404.
## Error in open.connection(structure(5L, class = c("curl", "connection"), conn_id = <pointer: 0x21d>),  : 
##   HTTP error 404.
## Error in open.connection(structure(6L, class = c("curl", "connection"), conn_id = <pointer: 0x21e>),  : 
##   HTTP error 404.
## Error in open.connection(structure(7L, class = c("curl", "connection"), conn_id = <pointer: 0x21f>),  : 
##   HTTP error 404.
## Error in open.connection(structure(8L, class = c("curl", "connection"), conn_id = <pointer: 0x220>),  : 
##   HTTP error 404.
## Error in open.connection(structure(9L, class = c("curl", "connection"), conn_id = <pointer: 0x22a>),  : 
##   HTTP error 404.
## Error in open.connection(structure(10L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(11L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(12L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(13L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(14L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(15L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(16L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(17L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(18L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(19L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(20L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(21L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(22L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(23L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(24L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(25L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(26L, class = c("curl", "connection" : 
##   HTTP error 404.
## Error in open.connection(structure(27L, class = c("curl", "connection" : 
##   HTTP error 404.
extensions_df %>% 
  mutate(namespace_url = namespace_url,
         namespace_contents = namespace_contents) %>% 
  unnest(namespace_contents) %>% 
  filter(str_detect(namespace_contents,"^export")) %>%
  mutate(fun = str_remove_all(namespace_contents,"export\\(|\\)")) %>% 
  mutate(fun_prefix = fun %>% str_extract(".*?_"))->
extensions_df_exports

extensions_df_exports %>% 
  remove_missing() %>% 
  select(repo_name, fun_prefix) %>% 
  ggedgelist:::ggedgelist_quick(layout = "fr", include_names = T)
## Warning: Removed 466 rows containing missing values or values outside the scale
## range.

extensions_df_exports %>% 
  filter(str_detect(namespace_contents,"^export")) %>%
  mutate(prefix = namespace_contents %>% str_extract(".*?_") %>% str_remove("export\\(")) %>% 
  # remove_missing() %>% 
  group_by(prefix) %>% 
  mutate(n = n()) %>% 
  # filter(prefix == "stat_") %>% 
  select(repo_name, prefix) %>% 
  ggedgelist:::ggedgelist_quick(layout = "fr", include_names = T)
## Warning in graph_from_data_frame(x, directed = directed): In `d' `NA' elements
## were replaced with string "NA"

extensions_df_exports %>%   
  group_by(fun_prefix) %>% 
  mutate(n = n()) %>% 
  filter(n > 10) %>% 
  mutate(repo_fun = paste0(repo_name, "::", fun)) %>% 
  select(fun_prefix, fun, repo_name) %>% 
  filter((fun_prefix %in% c("stat_", "facet_", "geom_", "coord_", "theme_", "scale_"))) %>% 
  pivot_longer(cols= c(repo_name, fun_prefix)) %>% 
  select(fun, value) %>% 
  ggedgelist:::ggedgelist_quick(layout = "fr", include_names = T)

library(tidyverse)
pkgs <- as_tibble(tools::CRAN_package_db())
gg_pkgs <- pkgs %>% 
  select(Package, Depends, Imports, Suggests) %>% 
  filter(
    str_detect(Package, "^gg"),
    if_any(-Package, ~ str_detect(.x, "ggplot2"))
  ) %>% 
  mutate(
    dep_grid = str_detect(Depends, "\\bgrid\\b") | str_detect(Imports, "\\bgrid\\b"),
    dep_dplyr = str_detect(Depends, "\\bdplyr\\b") | str_detect(Imports, "\\bdplyr\\b")
  ) %>% 
  drop_na()

gg_pkgs %>% 
  pivot_longer(cols = dep_grid:dep_dplyr) %>% 
  filter(value) %>% 
  select(Package, name, everything()) ->
gg_pkgs_edgelist


gg_pkgs_edgelist %>% 
  ggedgelist:::ggedgelist_quick(include_names = T, 
                                layout = "fr")

gg_pkgs_tbl_graph <- tidygraph::as_tbl_graph(gg_pkgs_edgelist)
  
gg_pkgs_tbl_graph %>% 
  tidygraph::activate(nodes) %>% 
  as_tibble() %>% 
  mutate(is_import = name %in% c("dep_grid", "dep_dplyr")) %>% 
  mutate(node_color = case_when(name == "dep_dplyr" ~ "magenta",
                                     name == "dep_grid" ~ "khaki4",
                                     TRUE ~ "darkgrey")) %>% 
  mutate(name = ifelse(name == "dep_grid", "imports grid", name)) %>% 
  mutate(name = ifelse(name == "dep_dplyr", "imports dplyr", name)) %>% 
  mutate(node_size = is_import*2.5 + .8) ->
gg_pkgs_tbl_graph_nodes
library(threejs)  
## Loading required package: igraph
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:lubridate':
## 
##     %--%, union
## The following objects are masked from 'package:dplyr':
## 
##     as_data_frame, groups, union
## The following objects are masked from 'package:purrr':
## 
##     compose, simplify
## The following object is masked from 'package:tidyr':
## 
##     crossing
## The following object is masked from 'package:tibble':
## 
##     as_data_frame
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
fed <-  
  tidygraph::as.igraph(gg_pkgs_tbl_graph)  
igraph::graph_attr(fed, "layout") <- NULL  

V(fed)$size <- gg_pkgs_tbl_graph_nodes$node_size
V(fed)$color <- gg_pkgs_tbl_graph_nodes$node_color
V(fed)$shape <- gg_pkgs_tbl_graph_nodes$name
E(fed)$size <- .5

graphjs(g = fed, bg = "gray10",  
        showLabels = T,  
        layout = list(  
          layout_with_fr(fed, dim = 3)),  
                  main = "")

Closing remarks, Other Relevant Work, Caveats